package pers.chy.chyappointmentplatform.Filter;

import org.springframework.core.annotation.Order;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;



//
// 配置获取Socket客户端IP
// 参考博客：https://blog.csdn.net/qq_37855749/article/details/118334271
//

@javax.servlet.annotation.WebFilter(filterName = "sessionFilter",urlPatterns = "/*")
@Order(1)
public class WebSocketFilter implements Filter {
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest req= (HttpServletRequest) request;
        req.getSession().setAttribute("ip",req.getRemoteHost());

        chain.doFilter(request,response);
    }
}
